<? FoundryView::includeTpl( 'adminMain:header' ) ?>

<script type="text/javascript" src="<?=Foundry::config('webpath')?>/javascript/admin/imageBucketRules.js"></script>

<div id="mainContent">

	<h2>Image Manager</h2>
	
	<a href="<?=FoundryView::helperLinkTo('imageBucketAdmin/upload')?>" class="actionLink">
		<img src="<?=Foundry::config('webpath')?>/images/admin/add.png" />
		new image</a>
	<span id="actionMessage"></span>
	<p />
		
	<?php
		$start = 0;
		if( FoundryRequest::get( 'start', 'num' ) ) {
			$start = FoundryRequest::get( 'start', 'num' );
		}
		$model = FoundryModel::factory( 'net.mode3.imageBucket:image' );
		$images = $model->find( 'order by *name asc limit '.$start.',11' );		

	?>
	<?php if( $images->length() > 0 ) : ?>
		<table style="border:0;width:100%"><tr><td>
		<?php if( $start > 0 ) : ?>
		<a href="<?=FoundryView::helperLinkTo('imageBucketAdmin/main/'.($start-10))?>" class="actionLink">
			<img src="<?=Foundry::config('webpath')?>/images/admin/arrow_left.png" alt="Previous Page" />
			previous page</a>
		<?php endif ?>
		</td><td style="text-align:right;">
		<?php if( $images->length() == 11 ) : ?>
		<a href="<?=FoundryView::helperLinkTo('imageBucketAdmin/main/'.($start+10))?>" class="actionLink">
			next page
			<img src="<?=Foundry::config('webpath')?>/images/admin/arrow_right.png" alt="Previous Next" /></a>
		<?php endif ?>
		</td></tr></table>
		<? $max = 10; if( count( $images ) < 10 ) { $max = count( $images ); } ?>
		<ul class="assetList">
		<? foreach( $images as $image ) : ?>
			<li id="imageContainer<?=$image->uid?>">
				<span class="label">
				<a href="<?=FoundryView::helperLinkTo('imageBucketAdmin/edit')?>/<?=$image->uid?>"><?=$image->name?></a>
				</span>
				<span class="describe">
					<a href="<?=$image->filePath?><?=$image->thumbNail?>" target="new">Thumbnail</a>
				</span>
				<span class="icons">
				<img src="<?=Foundry::config('webpath')?>/images/admin/cross.png" title="Delete this image" class="imageDelete" for="<?=$image->uid?>" />
				<? if( $image->published == 1 ) : ?>
					<img src="<?=Foundry::config('webpath')?>/images/admin/star.png" title="Publish this image" />
				<? else: ?>
					<img src="<?=Foundry::config('webpath')?>/images/admin/star_inactive.png" title="Publish this image" class="imagePublish" for="<?=$image->uid?>" id="imagePublishStatus<?=$image->uid?>" />
				<? endif ?>
				<a href="<?=$image->filePath?><?=$image->name?>" target="new" class="iconLink"><img src="<?=Foundry::config('webpath')?>/images/admin/world.png" title="Preview this image" /></a>
				</span>
			</li>
			<li id="infoBumper<?=$image->uid?>" style="display: none"></li>
		
		<? endforeach ?>
		</ul>
	<?php else: ?>	
		You don&#039;t have any images, why don&#039;t you upload some.
	<?php endif ?>
</div>

<? FoundryView::includeTpl( 'adminMain:footer' ) ?>